package twoD.IsoPfem;

import java.util.ArrayList;

public class Geometry implements IGeometry {

	private ArrayList<Node> nodes_;
	private ArrayList<IEdge> edges_;
	private ArrayList<IFace> faces_;

	public Geometry() {
		nodes_ = new ArrayList<Node>();
		edges_ = new ArrayList<IEdge>();
		faces_ = new ArrayList<IFace>();
	}

	public Geometry(Node... nodes) {
		this();
		for (Node n : nodes)
			nodes_.add(n);
	}

	public void addEdge(IEdge e) {
		edges_.add(e);
	}

	public void addFace(IFace f) {
		faces_.add(f);
	}

	@Override
	public Node getNodes(int i) {
		return nodes_.get(i);
	}

	@Override
	public ArrayList<Node> getNodes() {
		return nodes_;
	}

	@Override
	public int getNumberOfNodes() {
		return nodes_.size();
	}

	@Override
	public IEdge getEdges(int i) {
		return edges_.get(i);
	}

	@Override
	public ArrayList<IEdge> getEdges() {
		return edges_;
	}

	@Override
	public int getNumberOfEdges() {
		return edges_.size();
	}

	@Override
	public IFace getFaces(int i) {
		return faces_.get(i);
	}

	@Override
	public ArrayList<IFace> getFaces() {
		return faces_;
	}

	@Override
	public int getNumberOfFaces() {
		return faces_.size();
	}

	@Override
	public ArrayList<Integer> collectDofNumbers(int d) {
		ArrayList<Integer> dofNumbers_ = new ArrayList<Integer>();
		// collect enumeration for nodes
		for (int i = 0; i < getNumberOfNodes(); i++)
			for (int j = 0; j < d; j++)
				dofNumbers_.add(getNodes(i).getDofNumbers()[j]);
		// collect enumeration for edges
		for (int i = 0; i < getNumberOfEdges(); i++) {
			int[] tmp = getEdges(i).getDofNumbers();
			for (int j = 0; j < tmp.length; j++)
				dofNumbers_.add(tmp[j]);
		}
		// collect enumeration for faces
		for (int i = 0; i < getNumberOfFaces(); i++) {
			int[] tmp = getFaces(i).getDofNumbers();
			for (int j = 0; j < tmp.length; j++)
				dofNumbers_.add(tmp[j]);
		}
		return dofNumbers_;
	}

}
